home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pckey.zip / PCKEY.DOC < prev    next >
Text File  |  1991-03-24  |  3KB  |  125 lines

  1. I used Peter Norton's "Programmer's Guide to the IBM PC
  2. & PS/2", copyright 1988, published by Microsoft press,
  3. as the only reference in coding pckey.
  4.  
  5. The PCKey class provides access to the PC's keyboard through
  6. fast inline member functions.  Special characters are
  7. defined in the header for your convenience.  PCKey is not
  8. for use in Windows 3.0 programming -- use only for DOS
  9. applications!
  10.  
  11. Compile and run fastkey.cpp to set your keyboard's fastest
  12. typematic rate/delay.
  13.  
  14. Define TEST_PCKEY_CPP near the end of pckey.cpp to test the
  15. pckey.cpp module in a stand alone fashion.  Study the code
  16. in main() for an example of using the PCKey class.
  17.  
  18. Never instantiate any instance of the PCKey class.  There
  19. needs to be only one instance and that is done for you
  20. automatically.  The only instance of the PCKey class is
  21. "PC".
  22.  
  23. Member functions of the PCKey class are available via the
  24. instance "PC":
  25.  
  26.  
  27. PC.enhanced()    returns true if an extended keyboard is
  28.         detected.
  29.  
  30. PC.getch()    Returns the ascii code of the character
  31.         read.  Automatically calls extended BIOS
  32.         service for enhanced keyboards.
  33.  
  34. PC.ascii()    returns the ascii code of the last character
  35.         read by PC.getch() or PC.kbhit().
  36.  
  37. PC.scan()    returns the scan code of the last character
  38.         read by PC.getch() or PC.kbhit().
  39.  
  40. PC.shift()    returns the keyboard status flags.
  41.         Automatically calls extended BIOS service
  42.         for enhanced keyboards.
  43.  
  44.  
  45. The following boolean functions should be self explanatory.
  46.  
  47.  
  48.         PC.InsertStateActive()
  49.         PC.CapsLockActive()
  50.         PC.NumLockActive()
  51.         PC.ScrollLockActive()
  52.         PC.AltPressed()
  53.         PC.CtrlPressed()
  54.         PC.LeftShiftPressed()
  55.         PC.RightShiftPressed()
  56.         PC.ShiftPressed()
  57.  
  58.         ( The next group is automatically enabled
  59.             for enhanced keyboards )
  60.  
  61.         PC.SysReqPressed()
  62.         PC.CapsLockPressed()
  63.         PC.NumLockPressed()
  64.         PC.ScrollLockPressed()
  65.         PC.RightAltPressed()
  66.         PC.RightCtrlPressed()
  67.         PC.LeftAltPressed()
  68.         PC.LeftCtrlPressed()
  69.  
  70.  
  71. PC.setTypeMatic()    sets typematic rate/delay.
  72.  
  73. PC.putch()    writes asciiScanCode pair to keyboard
  74.         buffer.
  75.  
  76. PC.flush()    flushes the keyboard buffer.
  77.  
  78.  
  79.  
  80. The following code fragment demonstrates using the defined
  81. keys in pckey.hpp:
  82.  
  83.  
  84.     switch (PC.getch())  {
  85.     case 0:  switch(PC.scan())  {
  86.         case F1:
  87.             ...
  88.             break;
  89.         case AltM:
  90.             ...
  91.             break;
  92.         case Home:
  93.             ...
  94.             break;
  95.         case CtrlLArr:
  96.             ...
  97.             break;
  98.  
  99.         }
  100.         break;
  101.     case ESC:
  102.         ...
  103.         break;
  104.     case CR:
  105.         ...
  106.         break;
  107.     default:
  108.         ch = PC.ascii();
  109.         ...
  110.         break;
  111.     }
  112.  
  113.  
  114. I think you get the idea.  Just lookup the key you want
  115. in pckey.hpp.  If it's a special key then PC.getch()
  116. returns zero and you read the scan code from PC.scan().
  117. Be sure to read the comments for ExtendKey at the end
  118. of pckey.hpp.
  119.  
  120.  
  121. I hope that you find pckey useful!
  122. Please be sure to send me your comments,
  123. I'll answer as many as I can (time, postage and/or
  124. billing charges permitting).  John
  125.